
using BasicModuleOrm.Db_Context;
using BasicModuleOrm.Models;
using BasicModuleOrm.ProductRespository;
using BasicModuleOrm.ProductRespository.Respository;
using Microsoft.EntityFrameworkCore;

namespace BasicModuleOrm
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //数据库优先命令行
            //EFCore 数据库优先命令 程序报管理控制台运行命令
            //Scaffold-DbContext "Server=192.168.60.129;Port=3306;Database=gmall-2024;Uid=root;Pwd=123456;"  Pomelo.EntityFrameworkCore.MySql  -OutputDir Models -Context AppDBContext

            var builder = WebApplication.CreateBuilder(args);

            // Add services to the container.

            builder.Services.AddControllers();
            // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
            //builder.Services.AddEndpointsApiExplorer();
            builder.Services.AddSwaggerGen();
            //添加mysql数据库上下文 数据库优先
            //builder.Services.AddDbContext<AppDBContext>();

            //builder.Services.AddDbContext<EfCoreContext>(option =>
            //option.UseMySql("server=192.168.60.129;port=3306;database=AspNetCore_ORMs;uid=root;pwd=123456", new
            //    MySqlServerVersion("5.7.20-mysql")));

            //// 2、配置DapperContext
            //builder.Services.AddSingleton<DapperContext>();

            //// 3、配置SqlSugarContext
            //builder.Services.AddSingleton(new SqlSugarContext(builder.Configuration));

            //配置商品仓储
            //builder.Services.AddProductReposotory(option => option.UseSqlSugar());

            //配置通用仓储
            builder.Services.AddReposotory(option => option.UseSqlSugar());
            
            var app = builder.Build();

            // Configure the HTTP request pipeline.
            if (app.Environment.IsDevelopment())
            {
                app.UseSwagger();
                app.UseSwaggerUI();
            }

            app.UseAuthorization();


            app.MapControllers();

            app.Run();
        }
    }
}
